﻿namespace SharePointConsoleApplication1
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;

    using com.stifel.BranchMgmtDao;
    using com.stifel.BranchPromotion;
    using com.stifel.Extensions.ByteExtensions;
    using com.stifel.Extensions.FileStreamExtensions;
    using com.stifel.Extensions.Int64Extensions;
    using com.stifel.Extensions.StringExtensions;
    using com.stifel.SharePoint;

    using Microsoft.SharePoint;
    using Microsoft.SharePoint.Linq;

    public class TestPromotion
    {
        #region Fields

        const string currentRequestGuid = "d1d1910a-a9fa-408e-a2d6-ac0b53e40242";
        const string liveUrl = "http://win-pv542842fga:8888/sites/a725/branchsystems/brancheslive/";
        const string proposedUrl = "http://win-pv542842fga:8888/sites/a725/branchsystems/branchesproposed/";

        SPUserInfoExpanded _currentUser;

        #endregion Fields

        #region Properties

        Guid currentRequest
        {
            get
            {
                return new Guid( currentRequestGuid );
            }
        }

        SPUserInfoExpanded currentUser
        {
            get
            {
                if ( _currentUser == null )
                    _currentUser = new SPUserInfoExpanded
                    {
                        LoginName = "smallbusiness\administrator",
                        Name = "Administrator"
                    };
                return _currentUser;
            }
        }

        string targetSiteUrl
        {
            get
            {
                return liveUrl;
            }
        }

        #endregion Properties

        #region Methods

        public void Test_BranchInfoCopy( )
        {
            using ( SPSite spSite = new SPSite( proposedUrl ) )
            {
                using ( SPWeb currentWeb = spSite.OpenWeb( ) )
                {
                    BranchPromotion promotion = new BranchPromotion( currentRequest, currentUser, currentWeb, targetSiteUrl );
                    promotion.Copy( BranchPromotionArea.Info );
                    promotion.Copy( BranchPromotionArea.Photo );
                    promotion.Copy( BranchPromotionArea.Lease );
                    promotion.Copy( BranchPromotionArea.Personnel );
                    promotion.Copy( BranchPromotionArea.Unit );
                    promotion.Copy( BranchPromotionArea.Update );
                    promotion.Copy( BranchPromotionArea.NetworkEquipment );
                }
            }
        }

        #endregion Methods
    }

    class Program
    {
        #region Methods

        static void Main( string[ ] args )
        {
//System.Net.WebClient wc = new System.Net.WebClient( );
//wc.DownloadFile( "http://col.stb00.s-msn.com/i/B0/B1488C914ADD441B8D6799FC634ABF.jpg", @"c:\msn.jpg" );

            TestPromotion o = new TestPromotion( );
            o.Test_BranchInfoCopy( );
        }

        #endregion Methods
    }
}